import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],

  resolve: {
    alias: {
      '@': path.resolve(import.meta.dirname, 'src')
    }
  },

  server: {
    // 监听所有IP地址
    // host: '0.0.0.0',
    host: '0.0.0.0',
    allowedHosts: ['49fh140803jv.vicp.fun'],
    // 自动打开浏览器运行以下路径的页面
    open: '/',
    proxy: {
      '/api': {
        target: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      }
    }
  }
})
